<?php /* Smarty version Smarty-3.1.13, created on 2014-11-19 22:17:48
         compiled from "D:\PHPWeb\cms\templates\admin\subject\subject.tpl" */ ?>
<?php /*%%SmartyHeaderCode:131995450eec9a61f36-40305112%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'f5e425cc07aceddcaf1e667e20cb9c74928f95be' => 
    array (
      0 => 'D:\\PHPWeb\\cms\\templates\\admin\\subject\\subject.tpl',
      1 => 1416406664,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '131995450eec9a61f36-40305112',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.13',
  'unifunc' => 'content_5450eec9b46495_48116628',
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_5450eec9b46495_48116628')) {function content_5450eec9b46495_48116628($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ("admin/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
 <?php echo $_smarty_tpl->getSubTemplate ("admin/navibar.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
 <?php echo $_smarty_tpl->getSubTemplate ("admin/sidebar.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>


<link rel="stylesheet" type="text/css"
	href="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript"
	src="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<?php echo @constant('WEBSITE_URL');?>
public/assets/lib/ajaxupload.js"></script>
<style>
#addwin {
	margin: -500px 0 0 -280px;
	/* PLAY THE WITH THE VALUES TO SEE GET THE DESIRED EFFECT */
}
</style>
<script type="text/javascript">


//文件上传组件处理
jQuery(function () {
	 	var button = jQuery('#selectfile'), interval;//绑定事件
	var load = new AjaxUpload(button, {//绑定AjaxUpload
    action: "admin/upload/imgfileup",//文件要上传到的处理页面,语言可以PHP,ASP,JSP等
    type:"POST",//提交方式
    data:{//还可以提交的值
        module:"ajaxupload",
        type:jQuery("#__mstype__").attr("value") 
    },
    //选择文件后,是否自动提交.这里可以变成true,自己去看看效果吧.
    autoSubmit:false,
    name:'msUploadFile',//提交的名字
    onChange:function(file,ext){//当选择文件后执行的方法,ext存在文件后续,可以在这里判断文件格式
		$("#file_show").attr("value",file);
    },
    onSubmit: function (file, ext) {//提交文件时执行的方法
    	if(ext && /^(jpg)$/.test(ext)){
			//ext是后缀名
    		button.value = "upload…";
    		button.disabled = "disabled";
		}else{	
			alert("只支持 jpg的格式") ;
			return false;
		}
    },
    onComplete: function (file, response) {//文件提交完成后可执行的方法
        button.text('Select');
        this.enable();
        var obj = JSON.parse(response)
		import_modelhide();
    	$.messager.alert('信息',obj.message);
    	 $('#img').attr('value',obj.filename);
    }
	});	
		var submit=jQuery('#submit').click(function(){//触发提交的事件.与autoSubmit的设置有关,是否采用
			load.submit();
	});
});

function openUpfile(){
	import_modelshow();
}

function import_modelshow(){ 
	 $('#import_resource_myModal').modal('show');
}
function import_modelhide(){
	 $('#import_resource_myModal').modal('hide');
}



	 function modelshow(){ 
		 $('#addwin').modal('show');
	 }
	 function modelhide(){
		 $('#addwin').modal('hide');
	 }
	 
	 
	function addNewSubject(){
		$("#form").form('clear');
		modelshow();
	}
	
	function editSubject(){
		var select = getSelectSubject();
		if(select == null ){
			$.messager.alert('错误','请选择要修改的记录!');
			return;
		}
		$("#form").form('clear');
		modelshow();
		$("#form").form('load',select);
	
	}
	function removeSubject(){
		$.messager.confirm('删除确定','确定要删除当前选择的记录!',function(r){
		    if (r){
		    	var select = getSelectSubject();
				if(select == null ){
					$.messager.alert('错误','请选择要删除的记录!');
					return;
				}
				$.ajax({  
		            type: "POST",  
		            dataType: "json",  
		            url: '<?php echo @constant('WEBSITE_URL');?>
admin/subject/deleteSubject',
		            data: { id: select.id },  
		            success: function (data) {  
		             	$('#grid').datagrid('reload'); 
		            },  
		            error: function () {  
		            }  
		        });  
		    }
		});
		
	}

	function createAllSubject(){
		 $.post(
					'<?php echo @constant('WEBSITE_URL');?>
admin/subject/createAllSubject',
					null,
					function(data){ 
						$.messager.alert('消息','创建成功!');
				    	$('#grid').datagrid('reload'); 
					},
					"json"
		    );
	}
	function subjectAddOrModify(){
		  if(!$('#form').form('validate')){
		        return;
		     }
	    $.post(
				'<?php echo @constant('WEBSITE_URL');?>
admin/subject/saveOrModify',
				$('#form').serialize(),
				function(data){ 
					modelhide();
			    	$('#grid').datagrid('reload'); 
				},
				"json"
	    );
	}
	  
	function win_close(){
		modelhide();
	}


	function getSelectSubject(){
		var select  = $("#grid").datagrid('getSelected');
		if(select == null){
			return null;
		}
		return select;
	}


	
	function linkFormatter(val,row,index){
		return '<a target="_blank" href="'+val+'">查看</a>';
	}
		 
</script>

<div class="content">
	<div class="header">
		<div class="stats">
			<p class="stat">
				<!--span class="number"></span-->
			</p>
		</div>

		<h1 class="page-title">专题管理</h1>
	</div>

	<div class="container-fluid">
		<div class="row-fluid">


<div class="form-actions">
	<h3>专题管理,可以修改,删除添加</h3>
  <button type="button" class="btn btn-primary" onclick="addNewSubject()" >添加新专题</button>
  <button type="button" class="btn btn-info" onclick="editSubject()">修改专题</button>
  <button type="button" class="btn btn-danger" onclick="removeSubject()" >删除专题</button>
  <button type="button" class="btn btn-primary" onclick="createAllSubject()" >专题生成</button>
</div>
			<table id="grid"
				data-options="url:'admin/subject/getpage',fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: auto; height: 350px"
				  iconCls="icons-save" pagination="true"
				rownumbers="true">
				<thead>
					<tr>
						<th data-options="field:'role_id',hidden:true"></th> 
						<th data-options="field:'id',width:100,checkbox:true"></th>
						<th data-options="field:'name',width:100">专题名称</th>
						<th data-options="field:'img',width:100">图片</th>
						<th data-options="field:'url',width:100,formatter:linkFormatter">地址</th>
						<th data-options="field:'index',width:100">序列</th>
						<th data-options="field:'desc',width:100">描述</th>
						<th data-options="field:'create_time',width:100">创建时间</th>
					
					</tr>
				</thead>
			</table>

			<div id="addwin" class="modal hide fade">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h5>专题信息管理</h5>
				</div>
				<div class="modal-body">
					<form id="form" method="post" class="form-horizontal">
						<div class="control-group" hidden="true">
							<input type="text" name="id" hidden="true">
						</div>
						<div class="control-group">
							<label class="control-label" for="Text input">专题名称:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="name" name="name"
									 placeholder="专题名称">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="inputPassword">使用图片:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="img" name="img"
									placeholder="添加图片.可以使用上传"></input>
									<input type="button" onclick="openUpfile()" value="上传"></input>
							</div>
						</div>

						<div class="control-group">
							<label class="control-label"  >序列:</label>
							<div class="controls">
								<input type="text" id="index" name="index"
									placeholder="序列">
							</div>
						</div>


						<div class="control-group">
							<label class="control-label"  >模版:</label>
							<div class="controls">
								<select id="template" name="template"  >
								<option value="0">默认</option>
								<option value="1">未知</option>
							</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  >描述:</label>
							<div class="controls">
								<textarea rows="4"  id="desc" name="desc"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer" id="div_view">
					<button type="button" style="width: 100px;" class="btn btn-primary"
						onclick="subjectAddOrModify()">提交</button>
					<button type="button" onclick="win_close()" style="width: 100px;"
						class="btn">取消</button>

				</div>
			</div>
			
			
			<div></div>

<?php echo $_smarty_tpl->getSubTemplate ("admin/subject/subjectitems.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>



<div id="import_resource_myModal" class="modal hide fade">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal"
			aria-hidden="true">&times;</button>
		<h3>图片上传</h3>
	</div>
	<div class="modal-body">
	  <div class="control-group">
		  </div>
			<table id="uploadedName" class="table table-hover"  > 
				<tr>
				<td align="right"><a>上传文件名:</a></td>
					<td align="right"><input type="text" id="file_show" class="input-style4 textinput-w3"
						readOnly="true" /></td>
				<td align="left"><input type="button" class="btn"
			id="selectfile" value="选择上传文件" /> </td>
				</tr>
                </table>
	</div>
	  <div class="modal-footer">
    <a href="#" onclick="import_modelhide();" class="btn">关闭</a>
    <a  id="submit" class="btn btn-primary">提交</a>
  </div>
</div>
			<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
			<?php echo $_smarty_tpl->getSubTemplate ("admin/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
<?php }} ?>